package logic

import (
	"context"
	"zf/models/mysql"

	"zf/zfrpc/internal/svc"
	"zf/zfrpc/zfrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type OrderDelLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewOrderDelLogic(ctx context.Context, svcCtx *svc.ServiceContext) *OrderDelLogic {
	return &OrderDelLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *OrderDelLogic) OrderDel(in *zfrpc.OrderDelRequest) (*zfrpc.OrderDelResponse, error) {
	// todo: add your logic here and delete this line
	var order mysql.Order
	mysql.DB.Debug().Where("id=?", in.OrderId).Delete(&order)

	return &zfrpc.OrderDelResponse{
		UserName:     order.UserName,
		UserMobile:   order.UserMobile,
		Address:      order.Address,
		GoodHomeName: order.GoodHomeName,
		GoodName:     order.GoodName,
		Num:          int64(order.Num),
		Info:         order.Info,
		Price:        float32(order.Price),
	}, nil

}
